/**
 * @description atRelation的api
 * @author 印明帝
 */

const router = require('koa-router')()
const { loginCheck } = require('../../middleware/loginCheck')
const { getAtMeCount,getAtMeBlog,makeAsRead } = require('../../control/atRelation')

router.prefix('/api/at')

// 获取at人的count
router.post('/count',loginCheck,async (ctx,next) => {
  let {userId} = ctx.request.body
  
  ctx.body = await getAtMeCount(userId)
})

// 获取at的博客列表
router.get('/blog',loginCheck,async (ctx,next) => {
  let {id: userId} = ctx.session.userInfo
  let {index} = ctx.query
  // 设置为已读
  makeAsRead(userId)
  // 获取列表
  ctx.body = await getAtMeBlog(userId,index)
})



module.exports = router